<script setup>
import { ref } from 'vue'
import { globalToggleDarkMode } from '@/assets/js/global.js'

const isDarkMode = ref(false)
const toggleDarkMode = () => {
  isDarkMode.value = !isDarkMode.value
  globalToggleDarkMode()
}
</script>

<template>
  <div>
    <div
      class="bgcSwitch"
      @click="toggleDarkMode"
      :title="isDarkMode ? '切换亮色模式' : '切换暗色模式'"
    >
      {{ isDarkMode ? '🌞' : '🌙' }}
    </div>
    <el-backtop :bottom="60" :right="15">
      <div
        style="
          height: 100%;
          width: 100%;
          background-color: var(--el-bg-color-overlay);
          box-shadow: var(--el-box-shadow-lighter);
          text-align: center;
          line-height: 40px;
          color: #1989fa;
        "
      >
        UP
      </div>
    </el-backtop>
  </div>
</template>

<style scoped>
.bgcSwitch {
  position: fixed;
  width: 50px;
  height: 50px;
  right: 10px;
  bottom: 10px;
  border-radius: 50%;
  background-color: var(--bg-color, #ffffff);
  color: var(--text-color, #000);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s ease;
}
.bgcSwitch:hover {
  transform: scale(1.1);
}
</style>
